<template>
	<div>
		<el-form>
			<el-form-item label="待办名称:">
				<el-input v-model="form.name" placeholder="请输入待办名称"></el-input>
			</el-form-item>
			<el-form-item label="待办内容:">
				<el-input v-model="form.content" placeholder="请输入待办内容"></el-input>
			</el-form-item>
			<el-form-item>
				<el-date-picker v-model="date" type="datetimerange" value-format="yyyy-MM-dd HH:mm:ss" range-separator="至"
				 start-placeholder="开始日期" end-placeholder="结束日期">
				</el-date-picker>
			</el-form-item>
			<el-form-item>
				<el-button type="primary" @click="save()">立即创建</el-button>
				<el-button @click='cancle()'>取消</el-button>
			</el-form-item>
		</el-form>
	</div>
</template>
<script>
	import {
		Message
	} from 'element-ui';
	import axios from '../../utils/axiosutils.js';
	export default {
		name: '',
		data() {
			return {
				date: [],
				form: {
					name: '',
					content: '',
					stime: '',
					etime: ''
				}
			};
		},
		components: {},
		created() {},
		methods: {
			save() {
				if (this.form.name != null && this.form.content != null && this.date[0] != null) {
					this.form.stime = this.date[0];
					this.form.etime = this.date[1];
					axios.post("/todo/save", resp => {
						this.$emit('todoAdd');
					}, this.form)
				} else {
					Message.error("都是必填项哦")
				}
			},
			cancle() {
				this.$emit('todoAdd');
			}
		}
	};
</script>
<style scoped></style>
